#!/usr/bin/python3
# -*- coding: utf-8 -*-


import os

from src.plugin.aparser.manage.manager import Manager
from src.plugin.aparser.factory.datasource import Datasource
from src.plugin.aparser.system_config import PARSER_CONFIG_DIR, PARSER_CUSTOM_DIR, PARSER_REGEX_PATH

__here__ = os.path.dirname(os.path.abspath(__file__))


def main():
    param_config_file = os.path.join(PARSER_CONFIG_DIR, "beat_test.json")
    # param_config_file = os.path.join(PARSER_CONFIG_DIR, "beat_linux.json")
    datasource = Datasource(param_config_file)
    manager = Manager(PARSER_REGEX_PATH, PARSER_CUSTOM_DIR, datasource)
    temp_dir = os.path.join(__here__, 'data/temp')
    if not os.path.exists(temp_dir):
        os.makedirs(temp_dir)
    manager.parse(write=True, file_dir=temp_dir)
    # manager.parse(print=True)


if __name__ == "__main__":
    main()
